package com.ruoyi.dispatch.enums;

import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.compress.utils.Lists;

import java.util.*;

/**
 * 回采月计划列名枚举
 * @author wuxiaofang
 * @date 2025-05-20
 */
public enum ProductionMonthPlanCol {

    PRO_MONTH_PLAN_ID("proMonthPlanId","ID",false),
    MINE_ID("mineId","矿井ID",false),
    MONTH_DATE("monthDate","月份",true),
    DW("dw","队别",true),
    DB("db","队别id",false),
    SGDD("sgdd","施工地点id",false),
    SGDD_NAME("sgddName","施工地点",true),
    HCFS("hcfs","回采方式",false),
    JH("jh","月计划",true),
    XHCL("xhcl","循环产量",false),
    RXHGS("rxhgs","日循环个数",false),
    TS("ts","天数",false),
    YTJD("ytjd","月推进度",false),
    SGRQ("sgrq","施工日期",false),
    RS("rs","人数",false),
    CREATE_BY("createBy", "创建者", false),
    CREATE_TIME("createTime", "创建时间", true),
    UPDATE_BY("createBy", "更新者", false),
    UPDATE_TIME("updateTime", "更新时间", false);


    private final String code;//列名
    private final String title;//中文名
    private final boolean isDefault;//是否默认展示标识

    ProductionMonthPlanCol(String code, String title, boolean isDefault) {
        this.code = code;
        this.title = title;
        this.isDefault = isDefault;
    }

    public String getCode() {
        return code;
    }

    public String getTitle() {
        return title;
    }

    public boolean isDefault() {
        return isDefault;
    }
    /**
     * 根据code获取枚举的code和title
     * @param code
     * @return
     */
    public static Map getByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        Iterator<ProductionMonthPlanCol> iterator = Arrays.stream(ProductionMonthPlanCol.values()).iterator();
        while (iterator.hasNext()) {
            ProductionMonthPlanCol i = iterator.next();
            if (i.code.equals(code)) {
                HashMap map = new HashMap();
                map.put("title", i.getTitle());
                map.put("code", i.getCode());
                return map;
            }
        }
        return null;
    }
    //获取默认展示的列名
    public static List<Map<String, String>> getDefalutCols() {
        List<Map<String, String>> defaultCols = Lists.newArrayList();
        for (ProductionMonthPlanCol item : ProductionMonthPlanCol.values()) {
            if (item.isDefault) {
                Map map = new HashMap();
                map.put("code", item.getCode());
                map.put("title", item.getTitle());
                defaultCols.add(map);
            }
        }
        return defaultCols;
    }
}
